<?php


class WacFinalClothQcTestHistoryTable extends WacCommonTable
{
    
    public static function getInstance()
    {
        return Doctrine_Core::getTable('WacFinalClothQcTestHistory');
    }

    public function createByParams($params=array())
    {
        $obj = Doctrine::getTable(WacTable::$finalClothQcTestHistory)->create();
        $obj->setDispatchOrderId($params["dispatch_order_id"]);
        $obj->setQcFormId($params["qc_form_id"]);
        $obj->save();
    }

    public function findOneByAssocateForm($objDispatchOrder, $objQcForm, $isArr=false)
    {
        $orderId = is_object($objDispatchOrder) ? $objDispatchOrder->getId() : $objDispatchOrder;
        $formId = is_object($objQcForm) ? $objQcForm->getId() : $objQcForm;

        $objQuery = $this->createQuery('t1')
                ->select('t1.*')
                ->from("WacFinalClothQcTestHistory t1")
                ->where("t1.dispatch_order_id=? and t1.qc_form_id=?", array($orderId, $formId));

        if($isArr)
        {
            $dataResult = $objQuery->fetchOne(array(), Doctrine::HYDRATE_ARRAY);
        }
        else{
            $dataResult = $objQuery->fetchOne();
        }

        $objQuery->free();
        return $dataResult;
    }
}